#include "sdkGlobal.h"
#include "platform_global.h"
#include "platform_8583.h"


typedef struct
{
    Build8583HeadInfoFunc mBuildHeadFunc;
    SetPublicField *mSetPublicFieldList;
    u32 mSetPublicFieldListSize;
    SDK_8583_STFIELDDEF *mFieldAttrList;
    u8 mFieldAttrListSize;
    Transmit8583Listener mTransmit8583Listener;
    VerifyRecv8583BagFunc mVerifyRecv8583BagFunc;
    Judge8583ResponseFunc mJude8583ResponseFunc;
    Get8583ResponseErrMsg mGetResponseErrMsgFunc;
    Build8583MacFunc mBuildMacFunc;
    PackLengthHeader mPackLengthHeader;
    UnpackLengthHeader mUnpackLengthHeader;
    IsRecvComplete mIsRecvComplete;
} platform_8583_entity;

static platform_8583_entity g_platform_8583_entity;

void platform_8583_init()
{
    memset(&g_platform_8583_entity, 0x00, sizeof(platform_8583_entity));
}

void platform_8583_set_build_head_func(Build8583HeadInfoFunc func)
{
    g_platform_8583_entity.mBuildHeadFunc = func;
}

Build8583HeadInfoFunc platform_8583_get_build_head_func()
{
    return g_platform_8583_entity.mBuildHeadFunc;
}

void platform_8583_set_build_public_fields_func(SetPublicField *setPublicFieldList, u32 listSize)
{
    g_platform_8583_entity.mSetPublicFieldList = setPublicFieldList;
    g_platform_8583_entity.mSetPublicFieldListSize = listSize;
}

SetPublicField *platform_8583_get_build_public_fields_func(u32 *listSize)
{
    if (listSize != NULL) *listSize = g_platform_8583_entity.mSetPublicFieldListSize;
    return g_platform_8583_entity.mSetPublicFieldList;
}

void platform_8583_set_fields_attr(SDK_8583_STFIELDDEF *fieldAttrList, u32 listSize)
{
    g_platform_8583_entity.mFieldAttrList = fieldAttrList;
    g_platform_8583_entity.mFieldAttrListSize = listSize;
}

SDK_8583_STFIELDDEF *platform_8583_get_fields_attr(u32 *listSize)
{
    if (listSize != NULL) *listSize = g_platform_8583_entity.mFieldAttrListSize;
    return g_platform_8583_entity.mFieldAttrList;
}

void platform_8583_set_transmit_listener(Transmit8583Listener *listener)
{
    memcpy(&g_platform_8583_entity.mTransmit8583Listener, listener, sizeof(Transmit8583Listener));
}

Transmit8583Listener *platform_8583_get_transmit_listener()
{
    return &g_platform_8583_entity.mTransmit8583Listener;
}

void platform_8583_set_verify_recv_bag_func(VerifyRecv8583BagFunc func)
{
    g_platform_8583_entity.mVerifyRecv8583BagFunc = func;
}

VerifyRecv8583BagFunc platform_8583_get_verify_recv_bag_func()
{
    return g_platform_8583_entity.mVerifyRecv8583BagFunc;
}

void platform_8583_set_jude_response_func(Judge8583ResponseFunc func)
{
    g_platform_8583_entity.mJude8583ResponseFunc = func;
}

Judge8583ResponseFunc platform_8583_get_jude_response_func()
{
    return g_platform_8583_entity.mJude8583ResponseFunc;
}

void platform_8583_set_get_response_err_msg_func(Get8583ResponseErrMsg func)
{
    g_platform_8583_entity.mGetResponseErrMsgFunc = func;
}

Get8583ResponseErrMsg platform_8583_get_get_response_err_msg_func()
{
    return g_platform_8583_entity.mGetResponseErrMsgFunc;
}

void platform_8583_set_build_mac_func(Build8583MacFunc func)
{
    g_platform_8583_entity.mBuildMacFunc = func;
}

Build8583MacFunc platform_8583_get_build_mac_func()
{
    return g_platform_8583_entity.mBuildMacFunc;
}

void platform_8583_set_pack_length_header_func(PackLengthHeader func)
{
    g_platform_8583_entity.mPackLengthHeader = func;
}

PackLengthHeader platform_8583_get_pack_length_header_func(void)
{
    return g_platform_8583_entity.mPackLengthHeader;
}

void platform_8583_set_unpack_length_header_func(UnpackLengthHeader func)
{
    g_platform_8583_entity.mUnpackLengthHeader = func;
}

UnpackLengthHeader platform_8583_get_unpack_length_header_func(void)
{
    return g_platform_8583_entity.mUnpackLengthHeader;
}

void platform_8583_set_is_recv_complete_func(IsRecvComplete func)
{
    g_platform_8583_entity.mIsRecvComplete = func;
}

IsRecvComplete platform_8583_get_is_recv_complete_func(void)
{
    return g_platform_8583_entity.mIsRecvComplete;
}
